package cn.jobstart.service.impl;

import cn.jobstart.vo.ResumeTrainingExperienceMiniDomainVO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import cn.jobstart.modelExt.ResumeTrainingExperienceExt;
import cn.jobstart.dao.IResumeTrainingExperienceDao;
import cn.jobstart.searchExt.ResumeTrainingExperienceSearchExt;
import cn.jobstart.pubInter.IBaseDao;
import cn.jobstart.pubInter.AbstractBaseService;
import cn.jobstart.service.IResumeTrainingExperienceService;
import lombok.extern.slf4j.Slf4j;
import cn.jobstart.common.StringUtil;
import cn.jobstart.common.SkList;
import cn.jobstart.pubInter.exception.SkException;

import java.util.List;


/**
 * @author sunke
 * @Date 2023-09-06 15:00:21
 * @description ResumeTrainingExperienceService      培训经历
 */
@Service(value = "resumeTrainingExperienceService")
@Slf4j
public class ResumeTrainingExperienceServiceImpl extends AbstractBaseService<ResumeTrainingExperienceExt, ResumeTrainingExperienceSearchExt, String> implements IResumeTrainingExperienceService {

    @Resource(name = "resumeTrainingExperienceDao")
    private IResumeTrainingExperienceDao resumeTrainingExperienceDao;

    @Override
    public IBaseDao<ResumeTrainingExperienceExt, ResumeTrainingExperienceSearchExt, String> getDao() {
        return resumeTrainingExperienceDao;
    }


    /**
     * 培训经历
     *
     * @param resumeId
     * @return
     */
    @Override
    public String getTrainingExperienceStrByResumeId(String resumeId) {
        try {
            List<ResumeTrainingExperienceExt> list = getListByResumeId(resumeId);

            return StringUtil.getJsonArrayStrByList(list, ResumeTrainingExperienceMiniDomainVO.class);


        } catch (Exception e) {

        }
        return "";

    }

    /**
     * 根据简历
     *
     * @param resumeId
     * @return
     */
    @Override
    public List<ResumeTrainingExperienceExt> getListByResumeId(String resumeId) {
        if (StringUtil.isNullOrEmpty(resumeId)) {
            return null;
        }
        try {
            return getAllList(ResumeTrainingExperienceSearchExt.getInstance().setResumesIdEq(resumeId));
        } catch (SkException e) {
            return null;
        }
    }
}